#define _CRT_SECURE_NO_WARNINGS 1
#include "test.h"
Dlistnode* Buynode(Type a)
{

	Dlistnode* newnode = (Dlistnode*)malloc(sizeof(Dlistnode));
	newnode->date = a;
	newnode->next = NULL;
	newnode->prev = NULL;
}

void Print(Dlistnode* phead)
{
	Dlistnode* cur = phead->next;
	while (cur != phead)
	{
		printf("%d->", cur->date);
	}
	printf("\n");
}

void Pushback(Dlistnode* phead,Type a)
{
	assert(phead);
	Dlistnode* tail = phead->prev;
	Dlistnode* new = Buynode(a);

	new->prev = tail;
	new->next = phead;
	phead->prev = new;
	phead->prev = new;
	

}

void Pushfront(Dlistnode* phead,Type a)
{
	assert(phead);
	Dlistnode* first = phead->next;
	Dlistnode* new = Buynode(a);

	new->next = first;
	new->prev = phead;
	phead->next = new;
	phead->next->prev = new;


}

void Popfront(Dlistnode* phead)
{
	assert(phead);
	assert(phead->next != phead);
	Dlistnode* first = phead->next;
	Dlistnode* second = phead->next->next;

	phead->next = second;
	second->prev = phead;
	free(first);
	first = NULL;

}


void Popback(Dlistnode* phead)
{
	assert(phead);
	assert(phead->prev != phead);
	Dlistnode* first = phead->prev;
	Dlistnode* second = phead->prev->prev;

	second->next = phead;
	phead->prev = second;
	free(first);
	first = NULL;
}